package com.qf.common;

import com.alibaba.fastjson.JSON;
import com.qf.bean.Product;
import com.qf.bean.RespResult;

public class JSONUtils {

    public static String toJSONString (RespResult respResult){
        return JSON.toJSONString(respResult);
    }

    public static String toJSONString (int code,String msg) {
        return  toJSONString(code,msg,null);
    }

    public static String toJSONString(int code,String msg,Object data){
        RespResult result =new RespResult();
        result.setMsg(msg);
        result.setCode(code);
        result.setRepo(data);
        return toJSONString(result);
    }

    public static<T> T parseObject (String jsonString,Class<T> tClass){
        return JSON.parseObject(jsonString, tClass);
    }

}
